<template>
  <!-- 待派工 -->
  <el-main class="vertical">
    <el-container style="height:55%;">
      <basic-crud ref="topCrudRrf" :option="option" apiGetListUrl="mes/specificationTaskController/listUnDispatchTask"
                  class="curdTop" selectType="multiple"  @row-click="handleRowClick">
        <template #firstArticleFlag="{ row }">
          <el-tag v-if="row.firstArticleFlag === 'true'" type="danger">首件</el-tag>
        </template>
        <template #menu="{row}">
          <el-button  icon="circle-plus" text type="primary"
                      v-permission="'treatDispatching-SINGLEDISPATCH'" @click="handleSingleDispatching(row)">派工</el-button>
          <el-button  icon="sugar" text type="primary" v-permission="'treatDispatching-ADDPROBLEMINSEPC-ADDPROBLEMINSEPC'"
                      @click="onOpenFeedback(row)">填写问题反馈单</el-button>
        </template>
        <template #menu-left>
          <el-button
              type="primary" plain
              icon="circle-plus"
              :loading="batchLoading"
              v-permission="'treatDispatching-BATCHDISPATCH'"
              @click="onOpenBatchDispatching()"
          >批量派工</el-button>
        </template>
      </basic-crud>
    </el-container>

    <!-- 工序详情页面组件 -->
    <techne-deails style="height:45%" ref="technoDeailsRef" :hidden-btn="true" :hidden-form="true"
                   :must-show-menu="true" :autoLoad="false"></techne-deails>
  </el-main>
</template>

<script setup>
import {ref} from "vue";
import TechneDeails from "@/views/mes/techne/TechneDeails.vue";
import {ElMessage} from "element-plus";

const bottomHeight = ref((document.body.clientHeight - 120) * 0.45 - 75);//0.45是父容器的高度设为45%

const option = ref({
  highlightCurrentRow: true,
  calcHeight: bottomHeight.value + 90,
  statusBtn: true,
  multiple: true,
  addBtn: false,
  menu: false,
  column: [
    {
      label: "计划编号",
      prop: "sourceCode",
      minWidth: 220,
      search:true
    },
    {
      label: "项目号",
      prop: "workOrderCode",
      sortable: true,
      minWidth: 150,
      search: true,
      searchSpan:6,
    },
    {
      label: "产品型号",
      prop: "modelName",
      sortable: true,
      minWidth: 150,
      search: true,
      searchSpan:6,
    },
    {
      label: "产品编号",
      prop: "pdmProductCode",
      sortable: true,
      minWidth: 150,
      search: false,
    },
    {
      label: "产品名称",
      prop: "pdmProductName",
      sortable: true,
      minWidth: 150,
    },
    {
      label: "首件标识",
      prop: "firstArticleFlag",
      width: 150,
      slot: true,
    },
    {
      label: "规程编号",
      prop: "code",
      sortable: true,
      minWidth: 150,
      searchSpan:6,
      search: true,
    },

    {
      label: "规程名称",
      prop: "name",
      overHidden: true,
      sortable:true,
      width: 150,
    },
    {
      label: "版本",
      prop: "specificationRev",
      sortable: true,
      overHidden: true,
      width: 70,
    },
    {
      label: "产品主管",
      prop: "assignerName",
      hide:true,
      minWidth: 80,
    },
    {
      label: "计划开始日期",
      prop: "needStartDate",
      sortable: true,
      width: 120,
      formatter: (row) => {
        return formatDate(row.needStartDate, "yyyy-MM-dd");
      },
    },
    {
      label: "计划结束日期",
      prop: "needEndDate",
      sortable: true,
      width: 120,
      formatter: (row) => {
        return formatDate(row.needEndDate, "yyyy-MM-dd");
      },
    },{
      label:'关重件',
      prop: 'importantSign',
      display: false,
      width: 80,
      sortable: true,
      type: 'select',
      search: true,
      searchType: 'select',
      dicData: [{
        label:'关键件',
        value: '1'
      },{
        label: '重要件',
        value: '2'
      },{
        label: '普通件',
        value: '3'
      }]
    },{
      label:'数量',
      prop: 'quantity',
      width:70,
    },{
      label:'批次号',
      prop: 'batchNum',
      width: 180,
      overHidden: true
    },{
      label: '配套机型',
      prop: 'applyProduct',
      width: 130
    },
    {
      label: "紧急程度",
      prop: "exigencyLevel",
      display: false,
      width: 90,
      type: "select",
      dicData: [
        {
          label: "不紧急",
          value: "none",
        },
        {
          label: "一般",
          value: "normal",
        },
        {
          label: "紧急",
          value: "exigency",
        },
        {
          label: "非常紧急",
          value: "veryExigency",
        },
      ],
      formatter: (val) => {
        return val.exigencyLevelText;
      },
    },
    {
      label: "军检",
      prop: "armyCheck",
      display: false,
      width: 70,
      type: "switch",
      dicData: [{
        label: '否',
        value: 'false'
      },{
        label: '是',
        value:'true'
      }]
    }
  ]
});

const technoDeailsRef=ref(null)
const handleRowClick=(row) =>{
  technoDeailsRef.value?.loadOnlyBySpecTask(row, 'worker');
}

//批量派工
const batchLoading=ref(false);
const onOpenBatchDispatching=()=>{

}

//派工
const handleSingleDispatching=()=>{

}
//填写问题反馈单
const onOpenFeedback=()=>{

}
</script>

<style scoped>

</style>